
// 处理组队邀请 {"邀请id":"14","队伍id":"14"}
// @ts-ignore
export async function execute(client_id,message_json) {
    let login_characters = G.Characters.get_current_login_characters(client_id);
    let invite_data = G.TeamUtils.get_team_invite_cache(message_json["邀请id"], login_characters["id"]);

    let invite_characters = _CharactersData.get(message_json["邀请id"]);
    if (invite_characters !== undefined) {
        if (invite_data !== undefined) {
            if (invite_data["team_id"] !== message_json["队伍id"]) {
                ClientUtils.send_basic_prompt(client_id, "#R非法的邀请信息!")
            } else {
                if (G.TeamUtils.add_characters_to_team(client_id, invite_data["team_id"], login_characters["id"])) {
                    let invite_client_id = G.Characters.get_characters_client_id(invite_data["invite_id"]);
                    if (invite_client_id !== undefined) {
                        ClientUtils.send_client_message(invite_client_id, 7, `玩家#G${login_characters["名称"]}#同意了你的组队邀请`);
                    }
                    G.TeamUtils.send_team_message(invite_data["team_id"], `#G${login_characters["名称"]}#通过#G${invite_characters["名称"]}#的邀请加入了队伍`);
                }
            }
        } else {
            ClientUtils.send_basic_prompt(client_id, "#R邀请信息不存在!")
        }
    } else {
        ClientUtils.send_basic_prompt(client_id, "#R邀请人不存在或已下线!")
    }
}